<script setup>
import { dbNavBack } from '@/utils';
const systemInfo = uni.getSystemInfoSync();
const topHeaderHeight = systemInfo.statusBarHeight + 44; // 例如，statusBarHeight + 44px
const statusHeight = systemInfo.statusBarHeight + 'px';
</script>

<template>
	<view class="nav-bar"
		:style="{ height: topHeaderHeight, paddingTop: statusHeight, backgroundColor: mainColor, color: '#fff', '--heght': topHeaderHeight, '--statusHeight': statusHeight }">
		<image src="/static/icon/left-white.png" mode="scaleToFill" @click="dbNavBack" />
		<view class="middle">
			<slot></slot>
		</view>
	</view>
</template>

<style lang="scss" scoped>
.nav-bar {
	box-sizing: border-box;
	text-align: center;
	display: flex;
	align-items: center;
	justify-content: center;

	image {
		padding-left: 20rpx;
		width: 40rpx;
		height: 40rpx;
	}
}

.middle {
	flex: 1;
	height: 44px;
	line-height: 44px;
	padding: 0 60rpx;
	margin-right: 60rpx;
	box-sizing: border-box;
	white-space: nowrap;
	/* 防止文本换行 */
	overflow: hidden;
	/* 隐藏溢出的文本 */
	text-overflow: ellipsis;
	/* 使用省略号代替溢出的文本 */
}
</style>
